<?php
//App::import('Vendor', 'FileUpload.uploader');
//App::import('Config', 'FileUpload.file_upload_settings');
class CGalleryComponent extends Object{
	var $components = array( 'Auth','Session','RequestHandler');
	
	public function initialize(&$controller) {
        $this->controller = $controller;
        $this->data = $controller->data;  	
    }
	
	public function get_gallery($category_id,$params){
		$model =& $this->getModel();
	    if(!$model){
//	      $this->_error('FileUpload::removeFileById -- no model detected.');
	      return false;
	    }   
	    $limit = (isset($params['limit'])) ? $params['limit'] : false;
	    $order = (isset($params['order'])) ? $params['order'] : array('Gallery.lp');
		return $model->find('all',array('conditions'=>array('Gallery.category_id'=>$category_id),'order'=>$order,'limit'=>$limit));
	}
	
	function add(){
		
	}
	
	function &getModel($name = null) {
		$model = null;
		if (!$name) {
			$name = 'Gallery';
		}    
		if($name){
			if (PHP5) {
				$model = ClassRegistry::init($name);
			} else {
				$model =& ClassRegistry::init($name);
			}

			if (empty($model)) {
//				$this->_error('FileUpload::getModel() - Model is not set or could not be found');
				return null;
			}
		}
		return $model;
	}
}